<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<#include "../common/header.ftl">
    <script type="text/javascript" src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
</head>
<script>
    $(function () {
        $('#pagination').twbsPagination({
            totalPages:${result.pages},
            startPage:${result.pageNum},
            visiblePages:${result.pageSize},
            first: "首页",
            prev: "上一页",
            next: "下一页",
            last: "莫邪",

            onPageClick: function (event, page) {
                $('#currentPage').val(page);
                $("#searchForm").submit();
            }
        });

        $(".addBtn").click(function () {
            $("#editForm").clearForm()
            $("#myModal").modal('show')
        })

        $(".editBtn").click(function () {
            var data = $(this).data("jsonstr")
            $("#customertId").val(data.id)
            $("#name").val(data.name)
            $("#age").val(data.age)
            $("#gender").val(data.gender)
            $("#tel").val(data.tel)
            $("#qq").val(data.qq)
            $("#job").val(data.jobId)
            $("#source").val(data.sourceId)
            $("#myModal").modal('show')
        })

        $(".saveBtn").click(function () {
            $("#editForm").ajaxSubmit(function (data) {
                showMessager(data);
            })
        })


        $(".saveTraceBtn").click(function () {
            $("#customerTraceHistoryeDitForm").ajaxSubmit(function (data) {
                showMessager(data);
            })
        })

        $(".traceBtn").click(function () {
            var data = $(this).data("jsonstr")
            $("#history_customerId").val(data.id)
            $("#customerName").val(data.name)

            $("#customerTraceHistoryModel").modal('show')
        })

    })


</script>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">潜在客户管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/customer/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入姓名/电话">
                </div>
                <div class="form-group">
                    <label for="status">状态:</label>
                    <select class="form-control" id="status" name="status">
                        <option value="-3">全部</option>
                        <option value="-2">流失</option>
                        <option value="-1">开发失败</option>
                        <option value="0">潜在客户</option>
                        <option value="1">正式客户</option>
                        <option value="2">资源池客户</option>
                    </select>
                    <script>
                        $("#status option[value='${qo.status}']").prop("selected", true);
                    </script>
                </div>
                <button id="btn_query" class="btn btn-default">查询</button>
                <a class="btn btn-success addBtn">添加</a>
            </form>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>年龄</th>
                    <th>性别</th>
                    <th>电话</th>
                    <th>qq</th>
                    <th>职业</th>
                    <th>来源</th>
                    <th>营销人员</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${(entity.name)!}</td>
                    <td>${(entity.age)!}</td>
                    <td>${((entity.gender)==1)?string("男","女")}</td>
                    <td>${(entity.tel)!}</td>
                    <td>${(entity.qq)!}</td>
                    <td>${(entity.job.title)!}</td>
                    <td>${(entity.source.title)!}</td>
                    <td>${(entity.seller.name)!}</td>

                    <td><#if (entity.status)! == -2>
                        流失
                    <#elseif (entity.status)! == -1>
                        开发失败
                    <#elseif (entity.status)! == 0>
                        潜在客户
                    <#elseif (entity.status)! == 1>
                        正式客户
                    <#elseif (entity.status)! == 2>
                        客户池资源
                    </#if></td>
                    <td>
                        <a class="btn btn-info btn-xs editBtn " data-jsonstr='${(entity.jsonString)!}'>
                            <span class="glyphicon glyphicon-pencil "></span>编辑
                        </a>
                        <a class="btn btn-info btn-xs traceBtn " data-jsonstr='${(entity.jsonString)!}'>
                            <span class="glyphicon glyphicon-pencil "></span>跟进
                        </a>
                    </td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>

<div class="modal fade " tabindex="-1" id="myModal" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">客户编辑/保存</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customer/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" id="customertId" name="id">
                    <input type="hidden" id="statusId" name="status" value="${qo.status}">
                    <div class="form-group">
                        <label for="name" class="col-sm-3 control-label">客户名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="name" name="name" value="${(entity.name)!}"
                                   placeholder="请输入客户名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="age" class="col-sm-3 control-label">年龄：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="age" name="age" value="${(entity.age)!}"
                                   placeholder="请输入客户年龄">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="gender" class="col-sm-3 control-label">性别：</label>
                        <div class="col-sm-6">
                            <select name="gender" id="gender" class="form-control">
                                <option class="form-control" value="1">男</option>
                                <option class="form-control" value="0">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="tel" class="col-sm-3 control-label">电话：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="tel" name="tel" value="${(entity.tel)!}"
                                   placeholder="请输入客户电话">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="qq" class="col-sm-3 control-label">QQ：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="qq" name="qq" value="${(entity.qq)!}"
                                   placeholder="请输入客户QQ">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="job" class="col-sm-3 control-label">职业：</label>
                        <div class="col-sm-6">
                            <select name="job.id" class="form-control" id="job">
                            <#list (jobs)! as j>
                                <option class="form-control" value="${j.id}">${j.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="source" class="col-sm-3 control-label">来源：</label>
                        <div class="col-sm-6">
                            <select name="source.id" class="form-control" id="source">
                            <#list (sources)! as s>
                                <option class="form-control" value="${s.id}">${s.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary saveBtn">确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div class="modal fade " tabindex="-1" id="customerTraceHistoryModel" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">客户编辑/保存</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customerTraceHistory/saveOrUpdate.do" method="post"
                      id="customerTraceHistoryeDitForm">
                    <input type="hidden" id="customerTraceHistorytId" name="id">
                    <div class="form-group">
                        <label for="name" class="col-sm-3 control-label">客户名称：</label>
                        <div class="col-sm-6">
                            <input type="hidden" class="form-control" id="history_customerId" name="customer.id">
                            <input type="text" class="form-control" id="customerName" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="age" class="col-sm-3 control-label">跟进时间：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="traceTime" name="traceTime"
                                   onclick="WdatePicker()">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="qq" class="col-sm-3 control-label">跟进内容：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="traceDetails" name="traceDetails">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="job" class="col-sm-3 control-label">跟进方式：</label>
                        <div class="col-sm-6">
                            <select name="traceType.id" class="form-control" id="traceType">
                            <#list (traceTypes)! as t>
                                <option class="form-control" value="${t.id}" >${t.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="gender" class="col-sm-3 control-label">跟进结果：</label>
                        <div class="col-sm-6">
                            <select name="traceResult" id="traceResult" class="form-control">
                                <option class="form-control" value="1">差</option>
                                <option class="form-control" value="2">中</option>
                                <option class="form-control" value="33">优</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="tel" class="col-sm-3 control-label">备注：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="remark" name="remark">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="gender" class="col-sm-3 control-label">跟进类型：</label>
                        <div class="col-sm-6">
                            <select name="type" id="type" class="form-control">
                                <option class="form-control" value="0">潜在客户开发</option>
                                <option class="form-control" value="1">正式客户跟进</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary saveTraceBtn">确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
</html>